function refaseh(){
    tableIn.reload("Users");
}

var tableIn = null;

function rest(){
   refaseh();
}

layui.use(['table','form'],function () {
    var table = layui.table;
    var form = layui.form;

    tableIn = table.render({
        elem: '#demo',
        url: '/Primary/getUser?isd='+0,
        id:'Users'
        , page: true //开启分页
        , page: {
            layout: ['count', 'prev', 'page', 'next', 'limit'],//展示的按钮
            groups: 5,//展示的联想的页码数
            limit: 10,//每页的条数
            limits: [10, 20],//可选的每页条数
        },
        cols: [[
            {field: 'userId', title: 'ID', width: 80},
            {field: 'avatarUrl', title: '头像', width: 100,hide:'true',templet:function (data){
                    return '<img src="'+data.avatarUrl+'" style="height: 55px;width: 50px;">';
                }},
            {field: 'userAccount', title: '账户', width: 100},
            {field: 'userNickname', title: '账户昵称', width: 100},
            {field: 'stuName', title: '学生姓名', width: 100},
            {field: 'stu_id', title: '学生学号', width: 100},
            {field: 'profession', title: '所属专业', width: 100},
            {field: 'stuPoints', title: '量化分', width: 100},
            {field: 'graduation', title: '是否毕业', width: 100,templet:function (d){
                    if (d.graduation == 0){
                        return "毕业";
                    }else if (d.graduation == 1){
                        return "在校";
                    }else if (d.graduation >= 2){
                        return "待定中....";
                    }
                }},
            {field: 'entranceDate', title: '入学时间', width: 180},
            {field: 'graduationDate', title: '毕业时间', width: 180},
            {field: 'studyContent', title: '学习内容', width: 100},
            {field: 'isd', title: '用户分辨',align:'center',templet:function (d){
                    if (d.isd == 0){
                        return "进思用户";
                    }else if (d.isd == 1){
                        return "非进思用户";
                    }
                }},
            {field: 'cz', title: '操作', toolbar: '#barDemo',align:'center'}
        ]], parseData: function (res) {
            return {
                "code":res.state,//解析接口状态
                "msg":res.message,//解析提交文本
                "count":res.total,//解析数据长度
                "data":res.data//解析数据列表
            };
        }
    });

    // 监听工具条
    table.on('tool(test)', function (obj) {//注：tool是工具条时间名，test是table
        console.log(obj.data.userId);
        console.log(obj.data);
        var e = obj.event;

        if (e === 'watch') {
            // layer.msg("查看"+data.id+data.username);
            layer.open({
                type: 2,
                title: '查看',
                content: 'watch.html',
                area: ['50%', '90%'],
                id: 'bookTable',
                success: function (layero, index) {//弹出层成功弹出后的回调函数

                    // 父页面向子页面传参 -- iframe 层传数据
                    var body = layer.getChildFrame('body', index);//获取iframe页面
                    body.find('#avatarUrl').attr('src',obj.data.avatarUrl);
                    body.find('#userAccount').val(obj.data.userAccount);
                    body.find('#userNickname').val(obj.data.userNickname);
                    body.find('#stuName').val(obj.data.stuName);
                    body.find('#stu_id').val(obj.data.stu_id);
                    body.find('#profession').val(obj.data.profession);
                    body.find('#stuPoints').val(obj.data.stuPoints);
                    body.find('#graduation').val(obj.data.graduation);
                    body.find('#entranceDate').val(obj.data.entranceDate);
                    body.find('#graduationDate').val(obj.data.graduationDate);
                    body.find('#studyContent').val(obj.data.studyContent);

                    localStorage.setItem("head",obj.data.avatarUrl);
                    console.log(obj.data.avatarUrl);
                }
            })
        }
    });
    form.on('submit(gogo)', function (d) {
        d = d.field;
        console.log(d);
        table.reload('Users', {
            where: {
                userAccount: d.userAccount,
                userNickname: d.userNickname,
                profession: d.profession,
            }, page: {
                page: 1,
                limit: 10
            }
        })
    });
    $('#heui').click(function (){
        layer.open({
            type:2,
            title:'高级检索',
            content:'Seniors.html',
            area:['60%','60%']
        })
    })
});
function shaii(userAccount,userNickname,profession){
    layui.use('table', function () {
        var table=layui.table;

        // console.log(userAccount,idCard,phone,userEmail);
        table.reload('Users',{
            where:{
                userAccount:userAccount,
                userNickname: userNickname,
                profession: profession
            },page:{
                page: 1,
                limit:10
            }
        })
    })

}